﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Globalization;

namespace SLBIARVerify.ClassLib
{
    public class TagTypeToImageConvert : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            //ClassLib.NameCuidType tmp = value as ClassLib.NameCuidType;

            //if (tmp==null)
            //{
            //    throw new ArgumentNullException();
            //}
            string source = value as string;
            //switch (tmp.Type)
            switch (source)
            {
                case "Folder":
                    return "Resources/folder.jpg";
                case "CrystalReport":
                    return "Resources/report.jpg";
                case "Webi":
                    return "Resources/webi.jpg";
                case "Universe":
                    return "Resources/universe.jpg";
                default:
                    return "Resources/default.jpg";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class AlternativeCountColor : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Int32 tmp = (Int32)value;
            if (tmp == 1)
            {
                return new SolidColorBrush(Color.FromArgb(255, 241, 244, 249));
            }
            else
            {
                return new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class TagNameToTextConvert : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ClassLib.NameCuidType tmp = value as ClassLib.NameCuidType;

            if (tmp == null)
            {
                throw new ArgumentNullException();
            }
            return tmp.Name;

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class GroupHeaderTextCountConvert : IValueConverter
    {

        public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
        {
            CollectionViewGroup cvg = value as CollectionViewGroup;

            return string.Format("{0}", cvg.Items.Count);
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }

    public class GroupHeaderTextNameConvert : IValueConverter
    {

        public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
        {
            CollectionViewGroup cvg = value as CollectionViewGroup;

            return cvg.Name;
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }

    public class GroupHeaderImageConvert : IValueConverter
    {

        public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
        {
            CollectionViewGroup cvg = value as CollectionViewGroup;

            string source = cvg.Name.ToString();

            switch (source)
            {
                case "Folder":
                    return "Resources/folder.jpg";
                case "CrystalReport":
                    return "Resources/report.jpg";
                case "Webi":
                    return "Resources/webi.jpg";
                case "Universe":
                    return "Resources/universe.jpg";
                default:
                    return "Resources/default.jpg";
            }
          //  return string.Format("({0} Remaining){1}", cvg.Items.Count, cvg.Name);//((i) => ((CheckListEventDefinition)i).Complete == false && ((CheckListEventDefinition)i).Required == true));
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
